// ------------------------------------------------------------------------------------- //

abstract class AccountModel {
  AccountModel(this.username, this.password,
      {this.repeatPassword, this.role, this.token, this.uuid});
  String username;
  String password;
  String? repeatPassword;
  String? role;
  String? token;
  String? uuid;
}

class LoginRequestModel extends AccountModel {
  LoginRequestModel({
    required String username,
    required String password,
    String? uuid,
    String? token,
  }) : super(username, password, uuid: uuid, token: token);

  Map<String, dynamic> toJson() {
    return {
      'username': username.trim(),
      'password': (password.trim()),
      'uuid': uuid,
      'token': token,
    };
  }

  @override
  String toString() {
    return '{'
        'username: $username, '
        'password: ${(password.trim())}, '
        'token: $token, '
        'uuid: $uuid, '
        '}';
  }
}

class SignupModel extends AccountModel {
  SignupModel({
    required String username,
    required String password,
    required String role,
    String? token,
    String? uuid,
  }) : super(username, password, role: role, token: token, uuid: uuid);

  // Convert to JSON format
  Map<String, dynamic> toJson() {
    return {
      'username': username.trim(),
      'password': (password.trim()),
      'role': role!.trim(),
      'token': token,
      'uuid': uuid,
    };
  }

  // Create an instance from JSON
  factory SignupModel.fromJson(Map<String, dynamic> json) {
    return SignupModel(
      username: json['username'],
      password: json['password'],
      role: json['role'],
      token: json['token'],
      uuid: json['uuid'],
    );
  }

  @override
  String toString() {
    return '{'
        'username: $username, '
        'password: $password, '
        'role: $role, '
        'token: $token, '
        'uuid: $uuid, '
        '}';
  }
}

class ResetPwModel extends AccountModel {
  ResetPwModel({
    required String username,
    required String password,
    required String repeatPassword,
  }) : super(username, password, repeatPassword: repeatPassword);

  Map<String, dynamic> toJson() {
    return {
      'username': username.trim(),
      'password': (password.trim()),
      'repeatPassword': (repeatPassword!.trim()),
    };
  }

  @override
  String toString() {
    return '{'
        ' username: $username,'
        ' password: $password,'
        ' repeatPassword: $repeatPassword,'
        '}';
  }
}
